/*
 * File: LightMaterial.cs
 * Author: Gourav Das
 * Purpose: Class for LightMaterial
 * Created: May 19 2011
 */

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace _22yards.ThreeD
{
    /// <summary>
    /// This is a game component that implements Material.
    /// </summary>
    public class LightingMaterial : CMaterial
    {
        public float AmbientIntensity { get; set; }
        public Vector3 AmbientColor { get; set; }
        public Vector3 LightDirection { get; set; }
        public Vector3 LightColor { get; set; }
        public Vector3 SpecularColor { get; set; }
        public float SpecularPower { get; set; }
        public Vector3 DiffuseColor { get; set; }
        public float Shininess { get; set; }

        public LightingMaterial()
        {
            AmbientColor = new Vector3(1f, 1f, 1f);
            LightDirection = new Vector3(0, -1, -1);
            LightColor = new Vector3(1f, 1f, 1f);
            SpecularColor = new Vector3(1, 1, 1);
            DiffuseColor = new Vector3(1f, 1f, 1f);
            SpecularPower = 128f;
            AmbientIntensity = 1f;
            Shininess = 0;
        }

        public override void SetEffectParameters(Effect effect)
        {
            if (effect.Parameters["AmbientLightColor"] != null)
                effect.Parameters["AmbientLightColor"].SetValue(AmbientColor);
            if (effect.Parameters["LightDir"] != null)
                effect.Parameters["LightDir"].SetValue(LightDirection);
            if (effect.Parameters["LightColor"] != null)
                effect.Parameters["LightColor"].SetValue(LightColor);
            if (effect.Parameters["SpecularColor"] != null)
                effect.Parameters["SpecularColor"].SetValue(SpecularColor);
            if (effect.Parameters["DiffuseColor"] != null)
                effect.Parameters["DiffuseColor"].SetValue(DiffuseColor);
            if (effect.Parameters["SpecularPower"] != null)
                effect.Parameters["SpecularPower"].SetValue(SpecularPower);
            if (effect.Parameters["AmbientIntensity"] != null)
                effect.Parameters["AmbientIntensity"].SetValue(AmbientIntensity);
            if (effect.Parameters["Shininess"] != null)
                effect.Parameters["Shininess"].SetValue(Shininess);
        }

    }
}
